<%--
  Created by IntelliJ IDEA.
  User: 墨墨之家
  Date: 2021/10/31
  Time: 19:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>Title</title>
    <%--    http://localhost:8080/atcrowdfunding02-admin-webui/--%>
    <%--    <base href="http://localhost:8080/atcrowdfunding02-admin-webui/">--%>
    <base href="http://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">

    <script type="text/javascript" src="jquery/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script type="text/javascript">
        $(function () {
            // $("#btn01").click(function () {
            // alert(1);
            // $.ajax({
            //     "url": "TestAjax.html",
            //     "type": "post",
            //     "data": {
            //         "array": [1, 2, 3]
            //     },
            //     "dataType": "text",
            //     "success": function (data) {
            //         alert(data)
            //     }
            // })
            // $.getJSON("TestAjax.html", {"array": [1, 2, 3]}, function (response) {
            //     alert(response)
            // })
            $("#btn01").click(function () {
                $.ajax({
                    "url": "TestAjax.html",
                    "type": "post",
                    "data": {
                        "array": [5, 8, 12]
                    },
                    "dataType": "text",
                    "success": function (response) {
                        alert(response);
                    },
                    "error": function (response) {
                        alert(response);
                    }
                });
            });


            // });
            $("#btn02").click(function () {
                var array = [1, 2, 3]
                var s = JSON.stringify(array);
                $.ajax({
                    url: "TestAjax2.html",
                    type: "post",
                    data: s,
                    contentType: "application/json;character=UTF-8",
                    dataType: "text",
                    success: function (data) {
                        alert(data)
                    }
                })
            })

            $("#btn03").click(function () {
                var i = {
                    name: "大壮",
                    age: 19
                }
                var responseBody = JSON.stringify(i);
                $.ajax({
                    url: "TestAjax3.json",
                    type: "post",
                    data: responseBody,
                    dataType: "json",
                    contentType: "application/json;charset=UTF-8",
                    success: function (data) {
                        console.log(data)
                    },
                    error: function (response) {
                        console.log(response);
                    }
                })
            })
            $("#btn04").click(function () {
                layer.msg("layer弹框")
            })
        })
    </script>

</head>
<body>
<a href="TestController.html"> a</a>
<button id="btn01">testAjax</button>
<br>

<button id="btn02">testAjax2</button>
<br>
<button id="btn03">testAjax3</button>

<button id="btn04">点我弹框</button>
</body>
</html>
